package com.oocl.im.action.impl;

import com.oocl.im.action.IAction;
import com.oocl.im.constants.ServerConstants;
import com.oocl.im.constants.ServerMap;
import com.oocl.im.entity.Protocol;
import com.oocl.im.outputstream.impl.NetOutput;

import java.io.ObjectOutputStream;
import java.util.*;

/**
 * Created by WUJO5 on 7/15/2017.
 */
public class SynAction implements IAction {
    ObjectOutputStream oos;
    public void execute() {
        System.out.println("here is in member handle");
        Iterator iterator = ServerMap.socketMap.entrySet().iterator();
        List<String> list = new ArrayList<String>(ServerMap.clientMap.keySet());
        System.out.println(list);
        while (iterator.hasNext()) {
            Map.Entry entry = (Map.Entry) iterator.next();
            System.out.println("memember handle entry:  " +entry);

            Map<String,Object> params=new HashMap<>();
            params.put(ServerConstants.LIST,list);
            Protocol protocol = new Protocol(ServerConstants.SYN,params);
            System.out.println("memember handle protocol is :" +protocol);
            new NetOutput((ObjectOutputStream) entry.getValue()).write(protocol);
        }
    }
}
